from lxml import etree

if __name__ == '__main__':
    #实例化好了etree对象,且将被解析的源码加载到了该对象中
    tree = etree.parse('./test.html')
    # r = tree.xpath('/html/body/div')
    # r = tree.xpath('/html//div')
    # r = tree.xpath('//div')
    # r = tree.xpath('//div[@class="song"]')
    # r = tree.xpath('//div[@class="song"]//li[2]/text()')
    r = tree.xpath('//div[@class="song"]//a/@href')
    print(r)